package com.homework.util;

import com.homework.util.ResultMsg;

public class ResultUtil {
    public static ResultMsg success() {
        return success(null);
    }

    public static ResultMsg success(Object object) {
        ResultMsg result = new ResultMsg();
        result.setData(object);
        result.setCode(0);
        result.setMsg("success");

        return result;
    }

    public static ResultMsg error(Integer code, String msg) {
        ResultMsg result = new ResultMsg();
        result.setCode(code);
        result.setMsg(msg);

        return result;
    }

    public static ResultMsg error(Integer code, String msg, Object object) {
        ResultMsg result = new ResultMsg();
        result.setCode(code);
        result.setMsg(msg);
        if(object != null) {
            result.setError(object);
        }

        return result;
    }
}